import request from '@/utils/request'

// 创建投票结果
export function updateUserResult(data) {
  return request({
    url: '/vote/online/update',
    method: 'post',
    data: data
  })
}

// 获得投票结果
export function getUserResult(id) {
  return request({
    url: '/vote/online/get?id=' + id,
    method: 'get'
  })
}

// 获得投票结果分页
export function getUserResultPage(query) {
  return request({
    url: '/vote/online/page',
    method: 'get',
    params: query
  })
}

// 获得投票规则分页
export function getVotePage(query) {
  return request({
    url: '/vote/online/vote-page',
    method: 'get',
    params: query
  })
}


// 获得投票用户列表
export function getUserResultList(query) {
  return request({
    url: '/vote/online/list',
    method: 'get',
    params: query
  })
}

// 获得投票用户列表
export function getGroupName(query) {
  return request({
    url: '/vote/online/group-name',
    method: 'get',
    params: query
  })
}

// 判断用户是否已投票
export function userIsVote(query) {
  return request({
    url: '/vote/online/userIsVote',
    method: 'get',
    params: query
  })
}

// 判断ip是否已投票
export function ipIsVote(query) {
  return request({
    url: '/vote/online/ipIsVote',
    method: 'get',
    params: query
  })
}

// 导出投票结果 Excel
export function exportUserResultExcel(query) {
  return request({
    url: '/vote/online/export-excel',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}
